import 'package:my_flutter_core/my_flutter_core.dart';

class AccountGroup {
  AccountGroup({
    this.id,
    this.ownerId,
    this.ownerUsername,
    this.ownerFullName,
    this.ownerAvatarUrl,
    this.isOwner = false,
  });

  factory AccountGroup.fromJson(Map<String, dynamic> json) {
    return AccountGroup(
      id: json['id']?.toString(),
      ownerId: json['ownerId']?.toString(),
      ownerUsername: json['ownerUsername']?.toString(),
      ownerFullName: json['ownerFullName']?.toString(),
      ownerAvatarUrl: json['ownerAvatarUrl']?.toString(),
      isOwner: tryToConvert<bool>(json['isOwner'], (p) => p as bool),
    );
  }

  String? id;
  String? ownerId;
  String? ownerUsername;
  String? ownerFullName;
  String? ownerAvatarUrl;
  bool? isOwner;

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'ownerId': ownerId,
      'ownerUsername': ownerUsername,
      'ownerFullName': ownerFullName,
      'ownerAvatarUrl': ownerAvatarUrl,
      'isOwner': isOwner,
    };
  }

  AccountGroup clone() {
    return AccountGroup(
      id: id,
      ownerId: ownerId,
      ownerUsername: ownerUsername,
      ownerFullName: ownerFullName,
      ownerAvatarUrl: ownerAvatarUrl,
      isOwner: isOwner,
    );
  }
}
